package com.zlq.login.controller;

import com.google.gson.Gson;
import com.zlq.login.entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
@WebServlet(urlPatterns = "/postController")
public class PostController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("uu");
        User user = new User(2,"zhang");
        Gson gson = new Gson();
        gson.toJson(user);

        String id = req.getParameter("id");
        String name = req.getParameter("name");
        System.out.println(id);

        System.out.println(name);

        PrintWriter out = resp.getWriter();
        out.write("qwer");
        out.flush();
        out.close();
    }
}